﻿using System;
using UnityEngine;
using UnityEngine.UI;

public class LikeItem : UserIconItem
{
    public GameObject likeObj;
    public Text eduText;
    public Text jobText;
    public Text hometownText;

    MiniUserInfo m_Data;
    public MiniUserInfo data => m_Data;

    Action<LikeItem> m_onSelectItem;
    public void Init(MiniUserInfo userinfo, Action<LikeItem> onSelectItem)
    {
        m_Data = userinfo;
        m_onSelectItem = onSelectItem;

        if (userinfo == null)
            return;

        base.Init(userinfo.name, userinfo.birthYear, userinfo.locationCity, (int)userinfo.height, userinfo.icon);

        eduText.text = DataString.GetEducationString(userinfo.eduation);
        jobText.text = userinfo.job;
        hometownText.text = userinfo.hometownProvince + userinfo.hometownCity + "人";

        //if(likeObj)
    }

    void OnEnable()
    {
        StartCoroutine(UnityFunctions.AdjustItemsLayout(transform));
    }
    public void OnClick()
    {
        m_onSelectItem?.Invoke(this);
    }
}